const {
  baseUtils,
  fromUtils
} = require("../../utils/index");


// import Toast from 'path/to/@vant/weapp/dist/toast/toast';
const app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    buttonInfo: '获取验证码',
    buttonState: false,
    currentSteps: 2,
    array: [],
    errMsg: '',
    selectBusinessInfo: [],
    settlementArray: ['对公', '法人对私', '非法人对私'],
    pickerType: ['企业', '个体工商户', '小微'],
    bankList: [],
    bbankList: [],
    bankCityRange: [],
    bankCityCode: [],
    bankCityCode2: [],
    bankListCode: [],
    bbankListCode: [],
    bankSelect: '',
    categoryRange: [],
    categoryCodeRange: [],
    categoryCodeRange2: [],
    categoryCodeRange3: [],
    categoryNameValue: '',
    cityRange: [],
    cityAreaCode: [],
    cityAreaCode2: [],
    cityAreaCode3: [],
    // addressCity: '',
    basicInformation: {
      addressCode: '',
      addressName: '',
      detailedAddress: '',
      type: '',
      categoryCode: '',
      categoryName: '',
      billingType: 0,
      bankAccountName: '',
      bankAccountCode: '',
      bankPhoneNum: '',
      bankAddress: '', //开户行地址
      bankInfo: '', //银行信息
      bankBranch: '', //支行信息
      bankCardFirstImg: '', //银行卡照片正面照
      bankCardSecondImg: '', //银行卡照片反面照
      uniformity: 0,
      legalPersonName: '',
      legalPersonCardCode: '',
      // legalPersonSecular: 0,
      legalPersonCardValidity: '',

      // settlementPersonSecular: 0,
      contactsName: '',
      contactsCardCode: '',
      contactsCardValidity: '',
      mobile: '',
      contactsEmaill: '',
      customerServiceNumber: '',
      name: '',
      registrationCode: '',
      termValidity: '',
      abbreviationName: '',
      businessLicenseImg: '',
      contactsCardFirstImg: '',
      contactsCardSecondImg: '',
      legalPersonCardFirstImg: '',
      legalPersonCardSecondImg: '',
      termValidity: '',
      verification: '', //验证码
    },
    settlement: {
      settlementPersonCardCode: '',
      settlementPersonCardFirstImg: '',
      settlementPersonCardSecondImg: '',
      settlementPersonCardValidity: '',
      settlementPersonName: '',
    },
    basicInformationImg: {
      groupPhotoSalesmen: '', //业务员门头合照地址
      merchantLog: '', //商户log地址
      merchantPhotoImg: '', //商户门头照地址
      noLegalMaterials: '', //非法人证明材料地址  
      storeEnvironment: '', //店内环境地址
      storeReception: '', //店内前台地址
      supplementaryAgreement: '', //补充协议地址
      valueAddedAgreement: '', //商户增值协议地址
      accountPermit: '', //开户许可证地址
    },
    policy: {},
    uniformityBoolean: true,
    legalPersonSecularBoolean: true,
    settlementPersonSecularBoolean: true,
    groupPhoto: [{
        name: "merchantPhotoImg",
        url: "",
        type: "image",
        title: "商户门头照",
      },
      {
        name: "storeEnvironment",
        url: "",
        type: "image",
        title: "店内环境",
      },
      {
        name: "storeReception",
        url: "",
        title: "店内前台",
      },
      {
        name: "noLegalMaterials",
        url: "",
        title: "非法人证明材料",
      },
      {
        name: "accountPermit",
        url: "",
        title: "开户许可证",
      },
      {
        name: "groupPhotoSalesmen",
        url: "",
        title: "业务员门头合照",
      },
      {
        name: "valueAddedAgreement",
        url: "",
        title: "商户增值协议",
      },
      {
        name: "merchantLog",
        url: "",
        title: "商户logo",
      },
      {
        name: "supplementaryAgreement",
        url: "",
        type: "image",
        title: "补充材料",
      },
    ],
  },
  onInputCom(e) {
    const {
      detail,
      target
    } = e;
    if ('basicInformation' == target.dataset.key) {
      this.setData({
        [target.dataset.key]: {
          ...this.data[target.dataset.key],
          [target.dataset.name]: detail
        }
      })
    }
  },
  onStepUp(e) {
    this.setData({
      currentSteps: this.data.currentSteps - 1,
    });
    console.log(this.data.currentSteps);
  },
  onStepDown(e) {
    this.setData({
      currentSteps: this.data.currentSteps + 1,
    });
    console.log(this.data.currentSteps);
    this.goTop();
  },
  onStepDownAuthInfo(e) {
    const data = this.data.basicInformation
    for (let item of Object.values(data)) {
      if (item === '') {
        wx.showToast({
          title: '有未填项或未上传图片',
          icon: 'none'
        })
        break;
      } else {
        this.setData({
          currentSteps: this.data.currentSteps + 1,
        });
        this.goTop();
        break;
      }
    }
  },
  onStepDownAuth(e) {
    const verification = this.data.basicInformation.verification
    const mobile = this.data.basicInformation.mobile
    if (verification && verification.length === 6 && mobile && mobile.length === 11) {
      app.ajax.requestPost(app.api.checkSmsMsg, {
        "oldMobilePhone": mobile,
        "verifyCode": verification,
      }).then((res) => {
        // wx.showToast({
        //   title: '电话验证成功',
        //   icon: 'none'
        // })
        this.setData({
          currentSteps: this.data.currentSteps + 1,
        });
        this.goTop();
      })
    } else {
      wx.showToast({
        title: '请输入电话和验证码',
        icon: 'none'
      })
    }

  },
  onChangeSwitch(e) {},
  goTop(e) {
    // 一键回到顶部
    wx.pageScrollTo({
      scrollTop: 0,
    });
  },
  onSubmit(e) {
    console.log('this.data', this.data.basicInformation);
    app.ajax.requestPost(app.api.saveMerchantInfo, {
      ...this.data.basicInformation,
      ...this.data.settlement,
      ...this.data.basicInformationImg,
    }).then(res => {
      console.log('onSubmit res');
      wx.showToast({
        title: '提交成功',
        complete: () => {
          wx.navigateTo({
            url: '/pages/addTheMerchants/reviewf/index',
            success: function (res) {
              res.eventChannel.emit('acceptDataFromOpenerPage', {
                //data
              })
            }
          })
        }
      })
    })

    // wx.navigateTo({
    //   url: '/pages/addTheMerchants/reviewf/index',
    //   success: function (res) {
    //     res.eventChannel.emit('acceptDataFromOpenerPage', {

    //     })
    //   }
    // })


  },
  uploadPictures(e) {
    console.log(e);
    const {
      key,
      name
    } = e.currentTarget.dataset
    const {
      basicInformation,
      settlement
    } = this.data
    const that = this
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success(res) {
        wx.showLoading({
          title: '上传中',
        })
        const tempFilePaths = res.tempFilePaths[0]
        const filename = tempFilePaths.replace('http://', '')
        app.ajax.requestPost(app.api.policy, {}).then((res) => {
          const policy = res.data
          wx.uploadFile({
            url: policy.host,
            filePath: tempFilePaths,
            name: 'file',
            formData: {
              'name': filename,
              'key': policy.dir + filename,
              'OSSAccessKeyId': policy.accessKeyId,
              'policy': policy.policy,
              'signature': policy.signature,
              'success_action_status': '200'
            },
            success(res) {
              if (name === 'legalPersonCardFirstImg' || name === 'legalPersonCardSecondImg') {
                that.setData({
                  basicInformation: {
                    ...basicInformation,
                    [name]: policy.host + '/' + policy.dir + filename,
                  }
                })
              } else if (name === 'settlementPersonCardFirstImg' || name === 'settlementPersonCardSecondImg') {
                that.setData({
                  // basicInformation: {
                  //   ...basicInformation,
                  //   [name]: policy.host + '/' + policy.dir + filename,
                  // }
                  settlement: {
                    ...settlement,
                    [name]: policy.host + '/' + policy.dir + filename,
                  }
                })
              } else {
                that.setData({
                  basicInformation: {
                    ...basicInformation,
                    [name]: policy.host + '/' + policy.dir + filename,
                  }
                })
              }
              wx.hideLoading()

              app.ajax.requestPost(app.api.selectOCRDistinguish, {
                "distinguishType": key + '',
                "imageUrl": policy.host + '/' + policy.dir + filename
              }).then((res) => {
                console.log('selectOCRDistinguish', res);
                const {
                  idCardCode,
                  idCardName,
                  idCardValidity,
                  bankInfo,
                  bankInfoCode,
                  bankAccountCode,
                  merchantName,
                  termValidity,
                  registrationCode
                } = res.data
                if (key == 1) {
                  console.log('name', name);
                  if (name === 'legalPersonCardFirstImg' || name === 'legalPersonCardSecondImg') {
                    that.setData({
                      basicInformation: {
                        ...basicInformation,
                        [name]: policy.host + '/' + policy.dir + filename,
                        legalPersonName: idCardName ? idCardName : basicInformation.legalPersonName,
                        legalPersonCardCode: idCardCode ? idCardCode : basicInformation.legalPersonCardCode,
                        legalPersonCardValidity: idCardValidity ? idCardValidity : basicInformation.legalPersonCardValidity,
                      }
                    })
                  } else if (name === 'settlementPersonCardFirstImg' || name === 'settlementPersonCardSecondImg') {
                    that.setData({
                      basicInformation: {
                        ...basicInformation,
                        [name]: policy.host + '/' + policy.dir + filename,
                        settlementPersonName: idCardName ? idCardName : basicInformation.settlementPersonName,
                        settlementPersonCardCode: idCardCode ? idCardCode : basicInformation.settlementPersonCardCode,
                        settlementPersonCardValidity: idCardValidity ? idCardValidity : basicInformation.settlementPersonCardValidity,
                      }
                    })
                  } else {
                    that.setData({
                      basicInformation: {
                        ...basicInformation,
                        [name]: policy.host + '/' + policy.dir + filename,
                        contactsName: idCardName ? idCardName : basicInformation.contactsName,
                        contactsCardCode: idCardCode ? idCardCode : basicInformation.contactsCardCode,
                        contactsCardValidity: idCardValidity ? idCardValidity : basicInformation.contactsCardValidity,
                      }
                    })
                  }
                } else if (key == 2) {
                  that.setData({
                    basicInformation: {
                      ...basicInformation,
                      [name]: policy.host + '/' + policy.dir + filename,
                      bankAccountCode: bankAccountCode ? bankAccountCode : basicInformation.bankAccountCode,
                      bankInfo: bankInfo ? bankInfo : basicInformation.bankInfo
                    }
                  })
                } else if (key == 0) {
                  that.setData({
                    basicInformation: {
                      ...basicInformation,
                      [name]: policy.host + '/' + policy.dir + filename,
                      name: merchantName ? merchantName : basicInformation.merchantName,
                      registrationCode: registrationCode ? registrationCode : basicInformation.registrationCode,
                      termValidity: termValidity ? termValidity : basicInformation.termValidity
                    }
                  })
                }
              })

            },
            fail(res) {
              wx.hideLoading()
            }
          })
        })
      }
    })
  },
  getBankInfo(data) {
    app.ajax.requestPost(app.api.selectBank, {
      "bankCode": data.bankCode ? data.bankCode : '',
      "bankLevel": data.bankLevel ? data.bankLevel : 1,
      "bankName": data.bankName ? data.bankName : '',
      "bankParentCode": data.bankParentCode ? data.bankParentCode : '',
      "areaCode": data.areaCode ? data.areaCode : '',
    }).then((res) => {
      if (!data.bankLevel) {
        this.setData({
          bankList: res.data.map(item => item.bankName),
          bankListCode: res.data.map(item => item.bankCode)
        })
      } else if (data.bankLevel === 2) {
        this.setData({
          bbankList: res.data.map(item => item.bankName),
          bbankListCode: res.data.map(item => item.bankCode)
        })
      }
    })
  },
  bingBank(e) {
    const index = e.detail.value
    this.setData({
      basicInformation: {
        ...this.data.basicInformation,
        bankInfo: this.data.bankList[index],
        bankBranch: '',
        bankAddress: ''
      },
    })
  },
  bingBBank(e) {
    const index = e.detail.value
    console.log(index);
    this.setData({
      basicInformation: {
        ...this.data.basicInformation,
        bankBranch: this.data.bbankList[index]
      }
    })
  },
  uploadPicturesOther(e) {
    const {
      key,
      name
    } = e.currentTarget.dataset
    const {
      basicInformationImg,
    } = this.data
    const index = this.data.groupPhoto.findIndex((item) => item.name === name);
    const groupPhoto = this.data.groupPhoto;
    const that = this
    wx.chooseImage({
      count: 1,
      sizeType: ['original', 'compressed'],
      sourceType: ['album', 'camera'],
      success(res) {
        wx.showLoading({
          title: '上传中',
        })
        const tempFilePaths = res.tempFilePaths[0]
        const filename = tempFilePaths.replace('http://', '')
        app.ajax.requestPost(app.api.policy, {}).then((res) => {
          const policy = res.data
          wx.uploadFile({
            url: policy.host,
            filePath: tempFilePaths,
            name: 'file',
            formData: {
              'name': filename,
              'key': policy.dir + filename,
              'OSSAccessKeyId': policy.accessKeyId,
              'policy': policy.policy,
              'signature': policy.signature,
              'success_action_status': '200'
            },
            success(res) {
              const url = policy.host + '/' + policy.dir + filename
              groupPhoto[index].url = url;
              that.setData({
                groupPhoto,
                basicInformationImg: {
                  ...basicInformationImg,
                  [key]: url
                }
              })
              wx.hideLoading()
            },
            fail(res) {
              wx.hideLoading()
            }
          })
        })
      }
    })

  },
  InputChange(e) {
    console.log(e);
  },
  idCardChange: function (event) {
    const idCard = event.detail || event;
    var idcardReg = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$|^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
    if (idCard.length === 18 || idCard.length === 15) {
      if (!(idcardReg.test(idCard))) {
        this.setData({
          errMsg: '身份证号码有误'
        })
        wx.showToast({
          title: '身份证号码有误',
          duration: 2000,
          icon: 'none'
        });
      } else {
        this.setData({
          errMsg: ''
        })
      }
    }

  },
  telChange: function (e) {
    const value = e.detail.value
    const msg = fromUtils.checkIphone(value)
    if (msg) {
      app.showMsg(msg)
    } else {

    }
  },
  telAndFixed: function (event) {
    const number = event.detail.value || event;
    var rePhone = /^((\+?86)|(\(\+86\)))?1\d{10}$/;
    var Tel = /^((\+?86)|(\(\+86\)))?\d{3,4}-\d{7,8}(-\d{3,4})?$/;
    if (rePhone.test(number) || Tel.test(number)) {
      //是手机或者座机
      this.setData({
        errMsg: ''
      })
    } else {
      //
      this.setData({
        errMsg: '客服电话有误'
      })
      wx.showToast({
        title: '客服电话有误',
        duration: 2000,
        icon: 'none'
      });
    }
  },
  emailChange: function (event) {
    const email = event.detail.value
    if (!(/^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(email))) {
      this.setData({
        errMsg: '输入邮箱有误'
      })
      wx.showToast({
        title: '输入邮箱有误',
        duration: 2000,
        icon: 'none'
      });
    } else {
      this.setData({
        errMsg: ''
      })
    }



  },
  onLoad: function (options) {
    // const accountInfo = wx.getAccountInfoSync();
    // console.log('accountInfo',accountInfo);
    // wx.login({
    //   success(res) {
    //     if (res.code) {
    //       console.log('res', res);
    //       app.ajax.requestPost(app.api.reg, {
    //         wxCode: res.code,
    //       }).then((res) => {
    //         console.log(res)
    //       })
    //     } else {
    //       console.log('登录失败！' + res.errMsg)
    //     }
    //   }
    // })

    var that = this
    app.ajax.requestPost(app.api.selectBusinessInfo, {
      "businessLevel": 1,
      "businessParentCode": ""
    }).then((res) => {
      console.log(res)
      if (res.data) {
        const categoryRange = res.data.map(item => item.businessName)
        const categoryCodeRange = res.data.map(item => item.businessCode)
        app.ajax.requestPost(app.api.selectBusinessInfo, {
          "businessLevel": 2,
          "businessParentCode": "1"
        }).then((reslev2) => {
          const categoryRange2 = reslev2.data.map(item => item.businessName)
          const categoryCodeRange2 = reslev2.data.map(item => item.businessCode)
          app.ajax.requestPost(app.api.selectBusinessInfo, {
            "businessLevel": 3,
            "businessParentCode": categoryCodeRange2[0]
          }).then((reslev3) => {
            const categoryRange3 = reslev3.data.map(item => item.businessName)
            const categoryCodeRange3 = reslev3.data.map(item => item.businessCode)
            that.setData({
              categoryRange: [categoryRange, categoryRange2,
                categoryRange3
              ],
              categoryCodeRange,
              categoryCodeRange2,
              categoryCodeRange3,
            })
          })
        })

      }
    })
    app.ajax.requestPost(app.api.selectAreaInfo, {
      "areaCode": "",
      "areaLevel": "1",
      "areaName": "",
      "areaParentCode": "",
      "orderNum": 0
    }).then((res) => {
      console.log(res)
      if (res.data) {
        const city = res.data.map(item => item.areaName).reverse()
        const cityAreaCode = res.data.map(item => item.areaCode).reverse()
        app.ajax.requestPost(app.api.selectAreaInfo, {
          "areaLevel": "2",
          "areaParentCode": "110",
        }).then((reply) => {
          const city2 = reply.data.map(item => item.areaName)
          const cityAreaCode2 = reply.data.map(item => item.areaCode)
          app.ajax.requestPost(app.api.selectAreaInfo, {
            "areaLevel": "3",
            "areaParentCode": "1000",
          }).then((result) => {
            const city3 = result.data.map(item => item.areaName)
            const cityAreaCode3 = result.data.map(item => item.areaCode)
            that.setData({
              cityRange: [city, city2,
                city3
              ],
              cityAreaCode,
              cityAreaCode2,
              cityAreaCode3,
              bankCityRange: [city, city2],
              bankCityCode: cityAreaCode,
              bankCityCode2: cityAreaCode2,
            })
          })
        })

      }
    })
    this.getBankInfo({})
  },
  getCheckSmsMsg(e) {
    console.log(e);
    const {
      basicInformation
    } = this.data
    if (basicInformation.mobile !== '' && basicInformation.mobile.length === 11) {
      baseUtils.countDown(60, (text) => {
        if (text === '重新发送') {
          this.setData({
            buttonState: false,
            buttonInfo: text,
          })
        } else {
          this.setData({
            buttonInfo: text,
            buttonState: true
          })
        }

      })
      app.ajax.requestPost(app.api.sendSmsMsg, {
        oldMobilePhone: basicInformation.mobile
      }).then((res) => {
        console.log(res)
        wx.showToast({
          title: '发送成功',
        })
      })
    } else {
      wx.showToast({
        title: '请输入电话',
        icon: 'error'
      })
    }
  },
  bindPickerType(e) {
    this.setData({
      basicInformation: {
        ...this.data.basicInformation,
        type: e.detail.value
      }
    })
  },
  bindPickerChangeAddressCodes(e) {
    console.log('bindPickerChangeAddressCodes', e);
    const {
      cityAreaCode,
      cityAreaCode2,
      cityAreaCode3,
      cityRange,
      basicInformation
    } = this.data
    this.setData({
      // addressCity: cityRange[0][e.detail.value[0]] + '/' + cityRange[1][e.detail.value[1]] + '/' + cityRange[2][e.detail.value[2]],
      basicInformation: {
        ...basicInformation,
        addressName: cityRange[0][e.detail.value[0]] + ',' + cityRange[1][e.detail.value[1]] + ',' + cityRange[2][e.detail.value[2]],
        addressCode: cityAreaCode[e.detail.value[0]] + ',' + cityAreaCode2[e.detail.value[1]] + ',' + cityAreaCode3[e.detail.value[2]]
      }
    })
    console.log(this.data.basicInformation);
  },
  bindBankAddress(e) {
    const {
      bankCityRange,
      bankCityCode2,
      cityRange,
      basicInformation,
      cityAreaCode3,
      bankListCode,
      bankList
    } = this.data

    if (bankList && bankList.length > 0 && basicInformation.bankInfo) {
      const bankCodeIndex = bankList.findIndex(item => item == basicInformation.bankInfo)
      console.log(bankCodeIndex);
      this.getBankInfo({
        areaCode: bankCityCode2[e.detail.value[1]],
        bankLevel: 2,
        bankParentCode: bankListCode[bankCodeIndex]
      })
      this.setData({
        basicInformation: {
          ...basicInformation,
          bankAddress: bankCityRange[0][e.detail.value[0]] + ',' + bankCityRange[1][e.detail.value[1]],
          bankBranch: ''
        }
      })
    } else {
      wx.showToast({
        title: '请先选择银行信息',
        icon: 'none'
      })
    }


  },
  bindcolumnchangeBank(e) {
    const {
      bankCityCode,
      bankCityRange
    } = this.data
    if (e.detail.column === 0) {
      app.ajax.requestPost(app.api.selectAreaInfo, {
        "areaLevel": "2",
        "areaParentCode": bankCityCode[e.detail.value],
      }).then((res) => {
        console.log(res)
        if (res.data) {
          const city2 = res.data.map(item => item.areaName)
          const bankCityCode2 = res.data.map(item => item.areaCode)
          this.setData({
            bankCityRange: [bankCityRange[0], city2],
            bankCityCode2,
          })
        }
      })
    }
  },
  bindcolumnchangeAddressCodes(e) {
    const {
      cityAreaCode,
      cityAreaCode2,
      cityRange
    } = this.data
    console.log('bindcolumnchangeAddressCodes', e);
    if (e.detail.column === 0) {
      app.ajax.requestPost(app.api.selectAreaInfo, {
        "areaLevel": "2",
        "areaParentCode": cityAreaCode[e.detail.value],
      }).then((res) => {
        console.log(res)
        if (res.data) {
          const city2 = res.data.map(item => item.areaName)
          const cityAreaCode2 = res.data.map(item => item.areaCode)
          app.ajax.requestPost(app.api.selectAreaInfo, {
            "areaLevel": "3",
            "areaParentCode": cityAreaCode2[0],
          }).then((reply) => {
            console.log(reply);
            const city3 = reply.data.map(item => item.areaName)
            const cityAreaCode3 = reply.data.map(item => item.areaCode)
            this.setData({
              cityRange: [cityRange[0], city2,
                city3
              ],
              cityAreaCode2,
              cityAreaCode3
            })
          })

        }
      })
    }
    if (e.detail.column === 1) {
      app.ajax.requestPost(app.api.selectAreaInfo, {
        "areaLevel": "3",
        "areaParentCode": cityAreaCode2[e.detail.value],
      }).then((res) => {
        console.log(res);
        if (res.data) {
          const city3 = res.data.map(item => item.areaName)
          const cityAreaCode3 = res.data.map(item => item.areaCode)
          this.setData({
            cityRange: [cityRange[0], cityRange[1], city3],
            cityAreaCode3
          })
        }
      })
    }
  },
  bindcolumnchangeCategory(e) {
    const {
      categoryRange,
      categoryCodeRange,
      categoryCodeRange2,
      categoryCodeRange3,
    } = this.data
    var that = this
    console.log('bindcolumnchangeCategory', e);
    if (e.detail.column === 0) {
      app.ajax.requestPost(app.api.selectBusinessInfo, {
        "businessLevel": 2,
        "businessParentCode": categoryCodeRange[e.detail.value]
      }).then((res) => {
        if (res.data) {
          const categoryRange2 = res.data.map(item => item.businessName)
          const categoryCodeRange2 = res.data.map(item => item.businessCode)
          app.ajax.requestPost(app.api.selectBusinessInfo, {
            "businessLevel": "3",
            "businessParentCode": categoryCodeRange2[e.detail.value]
          }).then((reply) => {
            const categoryRange3 = reply.data.map(item => item.businessName)
            const categoryCodeRange3 = reply.data.map(item => item.businessCode)
            console.log('categoryRange3', categoryRange3);
            that.setData({
              categoryRange: [categoryRange[0], categoryRange2,
                categoryRange3
              ],
              categoryCodeRange2,
              categoryCodeRange3
            })
          })

        }
      })
    }
    if (e.detail.column === 1) {
      app.ajax.requestPost(app.api.selectBusinessInfo, {
        "businessLevel": "3",
        "businessParentCode": categoryCodeRange2[e.detail.value]
      }).then((res) => {
        if (res.data) {
          const categoryRange3 = res.data.map(item => item.businessName)
          const categoryCodeRange3 = res.data.map(item => item.businessCode)
          this.setData({
            categoryRange: [categoryRange[0], categoryRange[1], categoryRange3],
            categoryCodeRange3
          })
        }
      })
    }
  },
  bindchangeCategory(e) {
    console.log('bindchangeCategory', e);
    const {
      categoryRange,
      categoryCodeRange,
      categoryCodeRange2,
      categoryCodeRange3,
      basicInformation
    } = this.data
    this.setData({
      categoryNameValue: categoryRange[0][e.detail.value[0]] + '/' + categoryRange[1][e.detail.value[1]] + '/' + categoryRange[2][e.detail.value[2]],
      basicInformation: {
        ...basicInformation,
        categoryName: categoryRange[0][e.detail.value[0]] + ',' + categoryRange[1][e.detail.value[1]] + ',' + categoryRange[2][e.detail.value[2]],
        categoryCode: categoryCodeRange[e.detail.value[0]] + ',' + categoryCodeRange2[e.detail.value[1]] + ',' + categoryCodeRange3[e.detail.value[2]]
      }
    })
  },
  bindPickerChangeSelect(e) {
    this.setData({
      basicInformation: {
        ...this.data.basicInformation,
        billingType: Number(e.detail.value)
      }
    })
    console.log(this.data.basicInformation);
  },
  onSwitchUniformity(e) {
    this.setData({
      uniformityBoolean: e.detail,
      basicInformation: {
        ...this.data.basicInformation,
        uniformity: e.detail ? 0 : 1
      }
    })
  },
  onSwitchSecular(e) {
    this.setData({
      legalPersonSecularBoolean: e.detail,
      basicInformation: {
        ...this.data.basicInformation,
        legalPersonSecular: e.detail ? 0 : 1
      }
    })
  },
  onSwitchSecularsettlement(e) {
    this.setData({
      settlementPersonSecularBoolean: e.detail,
      basicInformation: {
        ...this.data.basicInformation,
        settlementPersonSecular: e.detail ? 0 : 1
      }
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
});